// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   GoEditor.java

package com.boci.clientapp.orderstatus.ui.control;

import com.boci.clientapp.main.ClientAppLoader;
import com.boci.clientapp.orderstatus.vo.OrderStatusDetailVO;
import com.boci.common.ui.control.CMURLButton;
import com.boci.common.util.MessagesConfigurator;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
import javax.swing.*;
import javax.swing.table.TableCellEditor;

public class GoEditor extends AbstractCellEditor
    implements TableCellEditor, ActionListener
{

    private void initGUI()
    {
        rootPanel.setBackground(Color.WHITE);
        FlowLayout layout = new FlowLayout(1, 0, -3);
        rootPanel.setLayout(layout);
        btnChange = new CMURLButton();
        btnChange.setMargin(new Insets(1, 1, 0, 0));
        btnChange.setActionCommand("CHANGE_EDIT");
        btnChange.addActionListener(this);
        rootPanel.add(btnChange);
        rootPanel.add(new JLabel("|"));
        btnCancel = new CMURLButton();
        btnCancel.setMargin(new Insets(1, 1, 0, 0));
        btnCancel.setActionCommand("CANCEL_REVIEW");
        btnCancel.addActionListener(this);
        rootPanel.add(btnCancel);
        rootPanel.add(new JLabel("|"));
        btnDetail = new CMURLButton();
        btnDetail.setMargin(new Insets(1, 1, 0, 0));
        btnDetail.setActionCommand("DETAIL");
        btnDetail.addActionListener(this);
        rootPanel.add(btnDetail);
    }

    public void setText(Locale pLocale)
    {
        MessagesConfigurator msgConf = ClientAppLoader.getMessagesConfigurator();
        btnChange.setText(msgConf.getUIMessages("ORDER_STATUS.CHANGE", pLocale));
        btnCancel.setText(msgConf.getUIMessages("ORDER_STATUS.CANCEL", pLocale));
        btnDetail.setText(msgConf.getUIMessages("ORDER_STATUS.DETAIL", pLocale));
        setFont(pLocale);
    }

    private void setFont(Locale pLocale)
    {
        btnChange.setFont(ClientAppLoader.getSmallPlainTextFont(pLocale));
        btnCancel.setFont(ClientAppLoader.getSmallPlainTextFont(pLocale));
        btnDetail.setFont(ClientAppLoader.getSmallPlainTextFont(pLocale));
    }

    public GoEditor(Locale pLocale)
    {
        rootPanel = new JPanel();
        strValue = null;
        initGUI();
        setText(pLocale);
    }

    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
    {
        Object obj = table.getValueAt(row, 8);
        if(obj instanceof OrderStatusDetailVO)
        {
            OrderStatusDetailVO vo = (OrderStatusDetailVO)obj;
            btnCancel.setEnabled(vo.isAllowCancel());
            btnChange.setEnabled(vo.isAllowChange());
        }
        if(row % 2 == 0)
            rootPanel.setBackground(new Color(255, 255, 200));
        else
            rootPanel.setBackground(Color.WHITE);
        return rootPanel;
    }

    public Object getCellEditorValue()
    {
        return strValue;
    }

    public void resetValue()
    {
        strValue = "";
    }

    public void actionPerformed(ActionEvent e)
    {
        strValue = e.getActionCommand();
        fireEditingStopped();
    }

    private JPanel rootPanel;
    private CMURLButton btnChange;
    private CMURLButton btnCancel;
    private CMURLButton btnDetail;
    private String strValue;
}
